package com.grandtech.insurance.common.utils;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class MapUtil {

    public static Map json2Map(String json) {
        try {
            JSONObject jsonObject = new JSONObject(json);
            Map<String, Object> map = new HashMap<>();
            Iterator it = jsonObject.keys();
            while (it.hasNext()) {
                String key = (String) it.next();
                Object value = jsonObject.get(key);
                map.put(key, value);
            }
            return map;
        } catch (Exception e) {
            return null;
        }
    }
}
